<?php
// Connecting to Redis server on localhost
$redis = new Redis ();
$redis->connect ( '127.0.0.1', 6379 );
echo "Connection to server sucessfully";
// check whether server is running or not
echo "Server is running: ".$redis->ping ();
  
 $redis->hmset ( "phone_num_key", array (
		'create_time' => "20150403",
		'interface_sn' => "operator_seq",
		'amount' => 1235 
) );

echo $redis->hget ( "phone_num_key", 'create_time' ) . "</br>";
echo $redis->hget ( "phone_num_key", "create_time" ) . "</br>";
$accept = array ();
$accept = $redis->hmget ( "phone_num_key", array (
		'create_time',
		'interface_sn1' 
) );
var_dump ( $accept );

$redis->hset ( 'user:1', 'name', 'Joe' );
echo "\n\t ";
echo $redis->hget ( 'user:1', 'name' );
echo "\n\t ";
var_dump ( $redis->exists ( 'test' ) ); // 结果：bool(true)
echo "\n\t ";

$redis->delete ( 'test' );
$redis->lpush ( "test", "111" );
$redis->lpush ( "test", "222" );
$redis->rpush ( "test", "333" );
$redis->rpush ( "test", "444" );
var_dump ( $redis->lpop ( "test" ) ); // 结果：string(3) "222"
                                // 返回列表 key 的长度。
echo $redis->llen ( 'test' );

 
